<template>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="计划名称" prop="name">
  <el-input v-model="ruleForm.name"></el-input>
</el-form-item>
<el-form-item label="计划时间" required>
  <el-col :span="11">
    <el-form-item prop="start">
      <el-date-picker type="date" placeholder="选择开始日期" v-model="ruleForm.start" style="width: 100%;"></el-date-picker>
    </el-form-item>
  </el-col>
  <el-col class="line" :span="2">-</el-col>
  <el-col :span="11">
    <el-form-item prop="end">
      <el-date-picker type="date" placeholder="选择结束日期" v-model="ruleForm.end" style="width: 100%;"></el-date-picker>
    </el-form-item>
<!--    <el-form-item prop="date2">-->
<!--      <el-time-picker placeholder="选择时间" v-model="ruleForm.date2" style="width: 100%;"></el-time-picker>-->
<!--    </el-form-item>-->
  </el-col>
</el-form-item>
  <el-form-item label="创建分组" prop="group">
    <el-input v-model="ruleForm.group"></el-input>
  </el-form-item>
  <el-form-item label="背诵总单词数" prop="number">
  <el-input v-model="ruleForm.number"></el-input>
</el-form-item>
  <el-form-item label="背诵日单词数" prop="day">
    <el-input v-model="ruleForm.day"></el-input>
  </el-form-item>
<el-form-item label="学习目的" prop="goal">
  <el-input type="textarea" v-model="ruleForm.goal"></el-input>
</el-form-item>
<el-form-item>
  <el-button type="primary" @click="submitForm(ruleForm)">立即创建</el-button>
  <el-button @click="resetForm(ruleForm)">重置</el-button>
</el-form-item>
</el-form>
</template>
<script>
import axios from "axios";
import Qs from "qs";
export default {
name:'WordTable',
  data(){
  return {
    ruleForm:{
      userid:window.sessionStorage.getItem("ID"),
      name:"",
      start:"",
      end:"",
      group:"",
      goal:"",
      number:"",
      day:""
    },
    rules:{
      name:"",
      start:"",
      end:"",
      group:"",
      goal:"",
      number:"",
      day:""
    }
  }
  },
  methods:{
  submitForm(ruleForm){
    axios({
      url:`/plan/add`,
      method:"put",
      data:ruleForm
    }).then(data=>{
      if(data.data.code===1000){
        this.$message({
          message: data.data.msg,
          type: 'success'
        });
      }else {
        this.$message.error(data.data.msg);
      }
    }).catch(()=>{
      this.$message.error('删除失败');
    })
  },resetForm(s){
    s={}
    }
  }
}
</script>